package org.nokatag.code;

import java.util.Random;

public class DiffuseImageOp extends AbstractTransformImageOp
{

    double tx[];
    double ty[];
    double amount;

    public DiffuseImageOp()
    {
        amount = 1.6000000000000001D;
    }

    public double getAmount()
    {
        return amount;
    }

    public void setAmount(double amount)
    {
        this.amount = amount;
    }

    protected synchronized void init()
    {
        tx = new double[256];
        ty = new double[256];
        for(int i = 0; i < 256; i++)
        {
            double angle = (6.2831853071795862D * (double)i) / 256D;
            tx[i] = amount * Math.sin(angle);
            ty[i] = amount * Math.cos(angle);
        }

    }

    protected void transform(int x, int y, double t[])
    {
        Random r = new Random();
        int angle = (int)(r.nextFloat() * 255F);
        t[0] = (double)x + tx[angle];
        t[1] = (double)y + ty[angle];
    }
}
